package pl.edu.uj.tcs.blef.utils;


public abstract class AbstractCard implements Card {

	protected Color color;
	
	public AbstractCard(Color color){
		this.color = color;
	}
	
	@Override
	public Color getColor(){
		return this.color;
	}
	
	@Override
	public int compareTo(Card o) {
		if(this.getColor().compareTo(o.getColor()) == 0){
			if(this.getPriority() < o.getPriority()) return -1;
			else if(this.getPriority() == o.getPriority()) return 0;
			else return 1;
		} else return this.getColor().compareTo(o.getColor());
	}
	
	@Override
	public boolean equals(Object o){
		if(o == null) return false;
		if(!(o instanceof Card)) return false;
		Card c = (Card)o;
		if(this.getCode().equals(c.getCode())) return true;
		else return false;
	}
	
	@Override
	public int hashCode(){
		return this.getCode().hashCode();
	}

	@Override
	public abstract String getCode();

	@Override
	public abstract String getName();

	@Override
	public abstract int getPriority();
}
